package com.JavaBasic;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.util.Scanner;

public class SocketSend {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		DatagramSocket socket = new DatagramSocket();
		
		while(true) {
			String sendMsg = sc.nextLine();
			if (sendMsg.equals("quit")) {
				break;
			} else {
				DatagramPacket pkaget = 
						new DatagramPacket(sendMsg.getBytes(), sendMsg.getBytes().length, InetAddress.getByName("127.0.0.1"), 20000);
				socket.send(pkaget);
			}
			
		}
		
		socket.close();
		sc.close();
	}
}
